<script>
  init({
    title: 'Show/Hide All Columns',
    desc: 'Show/Hide all columns:<br>`$table.bootstrapTable(\'showAllColumns\')`<br>`$table.bootstrapTable(\'hideAllColumns\')`.',
    links: ['bootstrap-table.min.css'],
    scripts: ['bootstrap-table.min.js']
  })
</script>

<div id="toolbar">
  <button id="button" class="btn btn-secondary">showAllColumns</button>
  <button id="button2" class="btn btn-secondary">hideAllColumns</button>
</div>
<table
  id="table"
  data-toggle="table"
  data-toolbar="#toolbar"
  data-height="460"
  data-show-columns="true"
  data-pagination="true"
  data-side-pagination="server"
  data-url="https://examples.wenzhixin.net.cn/examples/bootstrap_table/data">
  <thead>
    <tr>
      <th data-field="id" data-sortable="true" data-switchable="false">ID</th>
      <th data-field="name" data-sortable="true">Item Name</th>
      <th data-field="price" data-sortable="true">Item Price</th>
    </tr>
  </thead>
</table>

<script>
  var $table = $('#table')
  var $button = $('#button')
  var $button2 = $('#button2')

  function mounted() {
    $button.click(function() {
      $table.bootstrapTable('showAllColumns')
    })

    $button2.click(function() {
      $table.bootstrapTable('hideAllColumns')
    })
  }
</script>
